﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                    xmlns:services="clr-namespace:ApartmentBillsManager.Start.Services"
                    xmlns:common="clr-namespace:ApartmentBillsManager.Start.Common">

    <DataTemplate DataType="{x:Type services:CreateEditBill}">
        <DataTemplate.Resources>
            <ObjectDataProvider x:Key="BillCategories" MethodName="GetValues"
                            ObjectType="{x:Type System:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="common:BillCategory"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
        </DataTemplate.Resources>
        <StackPanel Orientation="Vertical">
            <ItemsControl ItemContainerStyle="{DynamicResource DefaultMargins}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Grid Margin="20">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="40"/>
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                        </Grid>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="Payer:"/>
                <ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Roommates}" DisplayMemberPath="Name" SelectedItem="{Binding Paid}"/>

                <TextBlock Grid.Row="0" Grid.Column="2" Text="Date Paid:"/>
                <DatePicker Grid.Row="0" Grid.Column="3" SelectedDate="{Binding DatePaid}"/>

                <TextBlock Grid.Row="1" Grid.Column="0" Text="Category:"/>
                <ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Source={StaticResource BillCategories}}" SelectedItem="{Binding Category}"/>

                <TextBlock Grid.Row="1" Grid.Column="2" Text="Amount:"/>
                <xctk:DoubleUpDown Grid.Row="1" Grid.Column="3" FormatString="C2" Value="{Binding Amount}"/>

                <TextBlock Grid.Row="2" Grid.Column="0" Text="Start Date:" VerticalAlignment="Stretch"/>
                <DatePicker Grid.Row="2" Grid.Column="1" SelectedDate="{Binding StartDate}"/>

                <TextBlock Grid.Row="2" Grid.Column="2" Text="End Date:"/>
                <DatePicker Grid.Row="2" Grid.Column="3" SelectedDate="{Binding EndDate}"/>

                <TextBlock Grid.Row="2" Grid.Column="4" Text="Total Days:"/>
                <TextBox Grid.Row="2" Grid.Column="5" Text="{Binding TotalDays, Mode=OneWay}" IsEnabled="False" />
                
                <TextBlock Grid.Row="3" Grid.Column="0" Text="Remark:"/>
                <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Remark}"/>

            </ItemsControl>

            <DockPanel HorizontalAlignment="Center" LastChildFill="False" Width="100" Margin="10">
                <Button DockPanel.Dock="Left" Content="Add" Command="{Binding CreateBillButtonCommand}" IsEnabled="{Binding CanAddBill}"/>
                <Button DockPanel.Dock="Right" Content="Cancel" Command="{Binding CancelBillButtonCommand}"/>
            </DockPanel>

        </StackPanel>
    </DataTemplate>
</ResourceDictionary>